perm filename PUPERP.C[11,HE] blob sn#688201 filedate 1982-12-06 generic text, type T, neo UTF8
/* LINTLIBRARY */
/*
 * puperrprint.c
 *
 * Interprets the Pup Data portion of an Error Pup.  Output
 * goes to the standard output.
 *
 * Jeffrey Mogul	Stanford	27-January-1981
 *
 */

#include <puplib.h>

puperrprint(pdata, pdlen)
char *pdata;			/* pointer to pup data buffer */
int	pdlen;			/* length of data buffer (bytes) */
{	/* */
	char	msgbuf[100];

	if (pdlen < 10) {
		printf("Pup Error: improperly formatted Error Pup\n");
		return(0);
		}
#ifdef	PUP__NNSO	
	printf("Pup Error: Error Pup contents:\n");
	printf("	Header of original Pup:\n");
	printf("		PupLength = %d\n", *(ushort *)&pdata[0]);
	printf("		PupType = %o\n", *(uchar *)&pdata[2]);
	printf("		PupTransport = %o\n", *(uchar *)&pdata[3]);
	printf("		PupID = %o\n", *(ulong *)&pdata[4]);
	printf("		PupDstHost = %o\n", *(uchar *)&pdata[8]);
	printf("		PupDstNet = %o\n", *(uchar *)&pdata[9]);
	printf("		PupDstSocket = %o\n", *(ulong *)&pdata[10]);
	printf("		PupSrcHost = %o\n", *(uchar *)&pdata[14]);
	printf("		PupSrcNet = %o\n", *(uchar *)&pdata[15]);
	printf("		PupSrcSocket = %o\n", *(ulong *)&pdata[16]);
#else
	printf("Tell Jeff Mogul to finish his implementation\n");
#endif
	printf("	Error code: %o",*(ushort*)&pdata[20]);

	if (pdlen>18)
		printf(" argument = %o\n",*(ushort*)&pdata[22]);
	
	movestring(&pdata[24],msgbuf,pdlen-24);
	msgbuf[pdlen-24] = 0;	/* null-terminate string */
	printf("	Error message: %s\n",msgbuf);
}